import { createRouter, createWebHashHistory, createWebHistory } from 'vue-router'
import HomeView from '@/views/HomeView.vue'
import SearchView from '@/views/SearchView.vue'
import NotFind from '@/views/NotFind.vue'

const routes = [
  // {path: '/search/:data?',name:'search', component: SearchView},
  // 正常加载
  // {path: '/', redirect:'/home'},
  // {path: '/home', component: HomeView},
  // {path: '/search', component: SearchView},
  // {path: '/:catchAll(.*)', component: NotFind }
  // 懒加载
  { path: '/', redirect: '/home' },
  { path: '/home', component: () => import('@/views/HomeView.vue') },
  { path: '/search', component: () => import('@/views/SearchView.vue') },
  { path: '/my', component: () => import('@/views/MyView.vue') },
  { path: '/:catchAll(.*)', component: () => import('@/views/NotFind.vue') },
]

const router = createRouter({
  // history: createWebHashHistory(),
  history: createWebHistory(),
  routes,
})

export default router
